package com.cskaoyan.controller.back;

import com.cskaoyan.bean.po.BasePageInfo;
import com.cskaoyan.bean.po.CommonData;
import com.cskaoyan.bean.po.MarketComment;
import com.cskaoyan.bean.vo.back.BaseRespVo;
import com.cskaoyan.service.back.CommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:评论管理控制器
 * @author: jzc
 * @since: 2022/10/12 21:02
 **/
@RestController
@RequestMapping("admin")
public class CommentController {
    @Autowired
    CommentService commentService;
    @RequiresPermissions("admin:comment:list")
    @GetMapping("comment/list")
    public BaseRespVo regionList(BasePageInfo basePageInfo,Integer userId,Integer valueId) {
        CommonData commonData =commentService.getCommentList(basePageInfo,userId,valueId);
        return BaseRespVo.ok(commonData);
    }
    @RequiresPermissions("admin:comment:delete")
    @PostMapping("comment/delete")
    public BaseRespVo regionList(@RequestBody MarketComment marketComment) {
        Integer effected=commentService.deleteComment(marketComment);
        if(effected==0){
            BaseRespVo.invalidData();
        }
        return BaseRespVo.ok();
    }
}
